<template>
  <div></div>
</template>

<script>
export default {
  name: 'OutsideView',
  inject: ['closeCurrent'],
  data() {
    return {}
  },
  mounted() {
    this.$nextTick(() => {
      this.goUrl()
    })
  },
  methods: {
    goUrl() {
      const link = this.$route.meta.link
      const query = this.$route.query
      this.gotoFullPage(link, query)
      this.closeCurrent()
    },
    gotoFullPage(path, query) {
      let url
      if (path.indexOf('http:') >= 0 || path.indexOf('https:') >= 0) {
        url = path
      } else {
        url = `${origin}${path}`
      }
      url = this.setUrlParams(url, query)
      window.open(url)
    },
    setUrlParams(url, obj) { // 跳转url设置路由参数
      Object.keys(obj).forEach((key, i) => {
        if (url.indexOf('?') === -1) {
          url += `?${key}=${obj[key]}`
        } else {
          url += `&${key}=${obj[key]}`
        }
      })
      return url
    }
  }
}
</script>

<style>
</style>
